***********************************************************************************************
***
***	INTERTEMPORAL EVIDENCE ON THE STRATEGY OF POPULISM IN THE US (Gennaro, Lecce, Morelli)
***	Replication Package
***  
*** Appendix - Table A8
***
***********************************************************************************************



clear
est clear 

* Indicate location of the replication package here
cd "/Replication Package"

**********************************************
* Upload Data                            *****
**********************************************


clear
est clear 
use "3_data/for_analysis/presidential_election_complete.dta", clear

egen mch_s = std(mch)
egen pop_dim2_s = std(pop_dim2)


drop if mch_s==.

**********************************************
*REGRESSIONS                             *****
**********************************************


eststo m1: reg pop_dim2_s i.trump length i.mcode, cl(MSANAME)
eststo m2: reg pop_dim2_s i.trump##c.mch_s length i.mcode, cl(MSANAME)
eststo m3: reg pop_dim2_s i.trump##c.mch_s##i.swing length i.mcode, cl(MSANAME)

eststo m4: reg pop_dim2_s c.mch_s##i.swing length i.mcode if trump==1, cl(MSANAME)
eststo m5: reg pop_dim2_s c.mch_s##i.swing length i.mcode if trump==0, cl(MSANAME)

eststo m6: reg pop_dim2_s i.trump##c.mch_s##i.swing i.mcode length i.statecode, cl(MSANAME)
eststo m7: reg pop_dim2_s i.trump##c.mch_s##i.swing i.mcode length i.statecode eduatt ancestry native , cl(MSANAME)
eststo m8: reg pop_dim2_s i.trump##c.mch_s##i.swing i.mcode length i.statecode eduatt ancestry native if commonstates==1, cl(MSANAME)

*reg pop_dim2_s i.trump##c.mch_s##i.swing i.mcode length i.statecode eduatt ancestry native if commonsmsa==1, cl(statecode)


esttab m1 m2 m3 m4 m5 m6 m7 m8 using "results/tables/tab3.tex", f label replace booktabs alignment(D{.}{.}{-1}) ///
s(N r2, fmt(0 2) label("Observations" "R-squared")) ///
nomtitles star(* 0.10 ** 0.05 *** 0.01) r2 b(3) se(3) brac nonotes



*************************
*  Linear combination
*************************


qui reg pop_dim2_s i.trump##c.mch_s##i.swing length i.mcode, cl(MSANAME)

* Insider in non competitive areas
lincom mch_s

* Insider in competitive areas
lincom mch_s + 1.swing#c.mch_s

* Outsider in non competitive areas
lincom mch_s + 1.trump#c.mch_s

* Outsider in competitive areas
lincom mch_s + 1.swing#c.mch_s + 1.trump#c.mch_s + 1.trump#1.swing#c.mch_s

